
(function($,W,D)
{
	
	 var EMAILFORM = {};
	 var validate;
	
	$.fn.validateFormErrors = function(object) {
		validate.showErrors(object);
	}

    EMAILFORM.UTIL =
    {	
    	
        setupFormValidation: function()
        {
        	//form validation rules
           var validator = $("#loginForm").validate({
                rules: {
                	login: {
          		      minlength: 3,
          		      required: true
          		    },
          		    password: {
          		      required: true,
          		      minlength: 3
          		    }
                },
                messages: {
         
                    login: {
                        required: "Please enter your user name",
                        minlength: "Your user name must be at least 3 characters"
                    },
                    password: {
                        required: "Please enter your password",
                        minlength: "Your password must be at least 3 characters"
                    }
                    
                },
                submitHandler: function(form) {
                	form.submit();
                },
                errorContainer: ".errorHeaderBox, .errorCalloutContainer",
                errorLabelContainer: ".errorCalloutContainer ul",
                wrapper: "li"
                //errorClass: "errorCallout"
            });
           return validator;
        }
    }
    
    //when the dom has loaded setup form validation rules
    $(D).ready(function($) {
    	validateForm();
    });
    
    var validateForm = function(){
    	validate = EMAILFORM.UTIL.setupFormValidation();
    }
      
})(jQuery, window, document);